angular.module('loginModule', [])
    .controller('loginCtrl', ['$scope','$http','$location', function ($scope,$http,$location) {
        $scope.submit = function(){
            $http.post('./admin/login.php',{
                postType:'login',
                username : $scope.username,
                password : $scope.password
            }).then(function(res){
                if(res.data.status == 1){
                    alert("登录成功");
                    $location.path("/home");
                }else{
                    if(res.data.status == 2){
                        var go = confirm('你还未注册，是否立即注册？');
                        if(go){
                            $location.path("/register");
                        }
                    }else{
                        alert('密码错误');
                    }
                }
            });
        }
    }]);